a = [1 for i in range(0, 1000+5)]
ss = input().split()
n = int(ss[0])
q = int(ss[1])

for i in range(0, q) :
	ss = input().split()
	L = int(ss[0])
	R = int(ss[1])
	for j in range(L, R + 1):
		a[j] = 0
ans = 0
for i in range(0, n + 1):
	ans = ans + a[i]
print(ans)